#include <bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005];
map<int,int> c;
queue<int> nu;
map<int,int> hu;
int main()
{
    freopen("duel4.in","r",stdin);
    freopen("duel4.out","w",stdout);
    int n,ans=0,minn,t;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[a[i]]++;
    }
    for(int i=0;i<n;i++)
    {
        if(b[i])
        {
            for(int j=0;j<b[i];j++)
            {
                nu.push(i);
            }
        }
    }
    minn=nu.front();
    hu[minn]++;
    nu.pop();
    while(!nu.empty() && nu.front()==minn)
    {
        nu.pop();
        hu[minn]++;
    }
    while(!nu.empty())
    {
        if(nu.front() > hu.begin()->first)
        {
            if(hu.begin()->second == 1)
                hu.erase(hu.begin());
            else
                hu[hu.begin()->first]--;
        }
        t=nu.front();
        nu.pop();
        hu[t]++;
    }
    while(!hu.empty())
    {
        if(hu.begin()->second == 1)
            hu.erase(hu.begin());
        else
            hu[hu.begin()->first]--;
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}
